package pratice.fengzhongye.interview;

import org.junit.Assert;
import org.junit.Test;
import sun.security.jca.GetInstance;

/**
 * @author 吴宇亮 on 2019/2/20 0020 12:14
 */
public class Lesson24_Singleton {

    @Test
    public void test(){
        Singleton instance = Singleton.getInstance();
        Singleton instance2 = Singleton.getInstance();
        Assert.assertSame(instance, instance2);
    }

}

class Singleton{

    private static final Singleton instance = new Singleton();

    private Singleton(){
        super();
    }

    public static Singleton getInstance(){
        return instance;
    }
}
